__date__ ="$Jun 28, 2010 9:39:46 PM$"

class Beer(object):
	''' A class for holding information about a single beer '''

	def __init__(self,brandInfo,prices, category):
		'''
		Constructor.
		
		@type brandInfo: 6-tuple
		@param brandInfo: contains (name, brewer,alcohol level, type of beer,
		description,pricelink)

		@type prices: tuple
		@param prices: (list of 3-tuple -> (quantity of beer, price,
		buying location), allSizes location link)

		@type category: string
		@param category: the the category of beer. premium, import, budget etc.
		
		'''

		mainUrl = r'''www.thebeerstore.ca'''
		mainPath = r'''/Beers/'''
		
		self.category = category
		''' the category of beer. premium, import, budget etc. '''
		
		self.name = brandInfo[0] #: the beer name
		self.brewer = brandInfo[1] #: the brewer
		self.alcohol = brandInfo[2] #: alcohol content
		self.type = brandInfo[3] #: booze type, ale, lager etc.
		self.description = brandInfo[4] #: the beer's description
		self.link = brandInfo[5] #:link for pricing information
		
		#self.name,self.brewer,self.alcohol,self.type,self.description,self.link\
		#= brandInfo
		
		self.link = mainUrl + mainPath + self.link
		
		
		self.pricing = []
		'''list of 3-tuple (quantity,price,location to buy link)'''
		
		pricingList = prices[0]


		if pricingList == []:
			self.pricing = None #if there is no pricing info, set empty
		else:
			for quantity,price,location in pricingList:
				location = mainUrl + mainPath + location
				self.pricing.append((quantity,price,location))

		if prices[1] == None: #if there is no all prices link set to empty
			self.allSizesPrice = None
			'''link for finding stores with all prices'''
		else:
			self.allSizesPrice = mainUrl + mainPath + prices[1]

	def splashInfo(self):
		'''
		@return: The information about a beer that can be found at its splash
		page. 6-tuple (name,brewer,alcohol,type,description,link)
		@rtype: tuple 
		'''
		splashPageInfo = (self.name, self.brewer, self.alcohol, self.type, 
						self.description, self.link)
		
		return splashPageInfo
	
	def pricingInfo(self):
		'''
		@return: The pricing information for this beer. A tuple consisting of
		(pricing <- a three tuple (quanity,price,location),
		allSizesPrice <- a link to where the user can find 
		this beer at stores over all price ranges).
		@rtype: tuple 
		'''
		return (self.pricing,self.allSizesPrice)
	
	def getCategory(self): return self.unicodeFilter(self.category)
	
	def getName(self): return self.unicodeFilter(self.name)
	
	def getBrewer(self): return self.unicodeFilter(self.brewer)
	
	def getAlcoholLevel(self): return self.alcohol
	
	def getType(self): return self.type
	
	def getDescription(self): return self.unicodeFilter(self.description)
	
	def getLocationLink(self): return self.link
	
	def unicodeFilter(self, string): 
		''' transform the string into a unicode encoding. 
		ignore any conversion errors based on interpreting 
		the string as ascii.
		@param string: string to be converted into unicode
		@type string: string
		
		@rtype: string
		@return: the passed in string converted to unicode
		'''
		
		return unicode(string, errors='ignore')
			
	def dumpSelf(self):
		''' print out information about this beer. '''

		#brandInfo = (self.name,self.brewer,self.alcohol,self.type,\
		#			self.description, self.link)

		#pricing = (self.pricing,self.allSizesPrice)
		#parse.dumpTotalInfo(brandInfo, pricing)
		
		print self.name
		print self.brewer,self.alcohol,self.type
		print self.description
		print self.link
	
		if self.pricing == None:
			print "No Pricing information available"	
		else:
			print self.pricing
			for quantity,price,location in self.pricing:
				print quantity,price,location
	
		if self.allSizesPrice == None:
			print "All sizes link empty"
		else:
			print self.allSizesPrice

if __name__ == "__main__":
    print "I am a beer object!";